/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.spreedairy.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.spreedairy.portal.model.Recommendation;
import com.spreedairy.portal.model.RecommendationModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the Recommendation service. Represents a row in the &quot;spreedairy_Recommendation&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.spreedairy.portal.model.RecommendationModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link RecommendationImpl}.
 * </p>
 *
 * @author SpreeDairy
 * @see RecommendationImpl
 * @see com.spreedairy.portal.model.Recommendation
 * @see com.spreedairy.portal.model.RecommendationModel
 * @generated
 */
public class RecommendationModelImpl extends BaseModelImpl<Recommendation>
	implements RecommendationModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a recommendation model instance should use the {@link com.spreedairy.portal.model.Recommendation} interface instead.
	 */
	public static final String TABLE_NAME = "spreedairy_Recommendation";
	public static final Object[][] TABLE_COLUMNS = {
			{ "recommendationId", Types.BIGINT },
			{ "itemId", Types.BIGINT },
			{ "userId", Types.BIGINT },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "createDate", Types.TIMESTAMP }
		};
	public static final String TABLE_SQL_CREATE = "create table spreedairy_Recommendation (recommendationId LONG not null primary key IDENTITY,itemId LONG,userId LONG,groupId LONG,companyId LONG,createDate DATE null)";
	public static final String TABLE_SQL_DROP = "drop table spreedairy_Recommendation";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.spreedairy.portal.model.Recommendation"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.spreedairy.portal.model.Recommendation"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.spreedairy.portal.model.Recommendation"),
			true);
	public static long COMPANYID_COLUMN_BITMASK = 1L;
	public static long GROUPID_COLUMN_BITMASK = 2L;
	public static long ITEMID_COLUMN_BITMASK = 4L;
	public static long USERID_COLUMN_BITMASK = 8L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.spreedairy.portal.model.Recommendation"));

	public RecommendationModelImpl() {
	}

	public long getPrimaryKey() {
		return _recommendationId;
	}

	public void setPrimaryKey(long primaryKey) {
		setRecommendationId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_recommendationId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return Recommendation.class;
	}

	public String getModelClassName() {
		return Recommendation.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("recommendationId", getRecommendationId());
		attributes.put("itemId", getItemId());
		attributes.put("userId", getUserId());
		attributes.put("groupId", getGroupId());
		attributes.put("companyId", getCompanyId());
		attributes.put("createDate", getCreateDate());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long recommendationId = (Long)attributes.get("recommendationId");

		if (recommendationId != null) {
			setRecommendationId(recommendationId);
		}

		Long itemId = (Long)attributes.get("itemId");

		if (itemId != null) {
			setItemId(itemId);
		}

		Long userId = (Long)attributes.get("userId");

		if (userId != null) {
			setUserId(userId);
		}

		Long groupId = (Long)attributes.get("groupId");

		if (groupId != null) {
			setGroupId(groupId);
		}

		Long companyId = (Long)attributes.get("companyId");

		if (companyId != null) {
			setCompanyId(companyId);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}
	}

	public long getRecommendationId() {
		return _recommendationId;
	}

	public void setRecommendationId(long recommendationId) {
		_recommendationId = recommendationId;
	}

	public long getItemId() {
		return _itemId;
	}

	public void setItemId(long itemId) {
		_columnBitmask |= ITEMID_COLUMN_BITMASK;

		if (!_setOriginalItemId) {
			_setOriginalItemId = true;

			_originalItemId = _itemId;
		}

		_itemId = itemId;
	}

	public long getOriginalItemId() {
		return _originalItemId;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_columnBitmask |= USERID_COLUMN_BITMASK;

		if (!_setOriginalUserId) {
			_setOriginalUserId = true;

			_originalUserId = _userId;
		}

		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public long getOriginalUserId() {
		return _originalUserId;
	}

	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_columnBitmask |= COMPANYID_COLUMN_BITMASK;

		if (!_setOriginalCompanyId) {
			_setOriginalCompanyId = true;

			_originalCompanyId = _companyId;
		}

		_companyId = companyId;
	}

	public long getOriginalCompanyId() {
		return _originalCompanyId;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
			Recommendation.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public Recommendation toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (Recommendation)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		RecommendationImpl recommendationImpl = new RecommendationImpl();

		recommendationImpl.setRecommendationId(getRecommendationId());
		recommendationImpl.setItemId(getItemId());
		recommendationImpl.setUserId(getUserId());
		recommendationImpl.setGroupId(getGroupId());
		recommendationImpl.setCompanyId(getCompanyId());
		recommendationImpl.setCreateDate(getCreateDate());

		recommendationImpl.resetOriginalValues();

		return recommendationImpl;
	}

	public int compareTo(Recommendation recommendation) {
		long primaryKey = recommendation.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		Recommendation recommendation = null;

		try {
			recommendation = (Recommendation)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = recommendation.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		RecommendationModelImpl recommendationModelImpl = this;

		recommendationModelImpl._originalItemId = recommendationModelImpl._itemId;

		recommendationModelImpl._setOriginalItemId = false;

		recommendationModelImpl._originalUserId = recommendationModelImpl._userId;

		recommendationModelImpl._setOriginalUserId = false;

		recommendationModelImpl._originalGroupId = recommendationModelImpl._groupId;

		recommendationModelImpl._setOriginalGroupId = false;

		recommendationModelImpl._originalCompanyId = recommendationModelImpl._companyId;

		recommendationModelImpl._setOriginalCompanyId = false;

		recommendationModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<Recommendation> toCacheModel() {
		RecommendationCacheModel recommendationCacheModel = new RecommendationCacheModel();

		recommendationCacheModel.recommendationId = getRecommendationId();

		recommendationCacheModel.itemId = getItemId();

		recommendationCacheModel.userId = getUserId();

		recommendationCacheModel.groupId = getGroupId();

		recommendationCacheModel.companyId = getCompanyId();

		Date createDate = getCreateDate();

		if (createDate != null) {
			recommendationCacheModel.createDate = createDate.getTime();
		}
		else {
			recommendationCacheModel.createDate = Long.MIN_VALUE;
		}

		return recommendationCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{recommendationId=");
		sb.append(getRecommendationId());
		sb.append(", itemId=");
		sb.append(getItemId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("com.spreedairy.portal.model.Recommendation");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>recommendationId</column-name><column-value><![CDATA[");
		sb.append(getRecommendationId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>itemId</column-name><column-value><![CDATA[");
		sb.append(getItemId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = Recommendation.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			Recommendation.class
		};
	private long _recommendationId;
	private long _itemId;
	private long _originalItemId;
	private boolean _setOriginalItemId;
	private long _userId;
	private String _userUuid;
	private long _originalUserId;
	private boolean _setOriginalUserId;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _companyId;
	private long _originalCompanyId;
	private boolean _setOriginalCompanyId;
	private Date _createDate;
	private long _columnBitmask;
	private Recommendation _escapedModelProxy;
}